package cn.xdf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/demo04")
public class Demo04Controller_RequestHeader {

    @GetMapping("/demo01")
    public void demo01(@RequestHeader String Host,
                       HttpServletResponse response)throws IOException{
        response.setContentType("text/html;charset=utf8");
        response.getWriter().write("Host:"+Host+"<hr/>");
    }

    @GetMapping("/demo02")
    public void demo02(@RequestHeader String username,
                       HttpServletResponse response) throws IOException{
        response.setContentType("text/html;charset=utf8");
        response.getWriter().write("username:"+username+"<hr/>");
    }
}
